//
//  JHJTabBarController.m
//  项目
//
//  Created by dllo on 16/5/8.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "JHJTabBarController.h"
#import "JHJTabBarCollectionViewCell.h"

@interface JHJTabBarController ()<UICollectionViewDataSource, UICollectionViewDelegate>


@property (nonatomic, retain)UICollectionView *collectionView;

@end

@implementation JHJTabBarController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.tabBar removeFromSuperview];
    [self creatView];
    
}

- (void)creatView {
    
    UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, HEIGHT - 100, WIDTH, 100)];
    [self.view addSubview:contentView];
    contentView.backgroundColor = [UIColor whiteColor];
    [contentView release];
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(WIDTH - 20, 80);
    flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    flowLayout.minimumInteritemSpacing = 20;
    flowLayout.minimumLineSpacing = 20;
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 100) collectionViewLayout:flowLayout];
    self.collectionView.backgroundColor = [UIColor whiteColor];
    [contentView addSubview:self.collectionView];
    [flowLayout release];
    [_collectionView release];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [self.collectionView registerClass:[JHJTabBarCollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
    self.collectionView.pagingEnabled = YES;
    self.collectionView.showsHorizontalScrollIndicator = NO;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 20;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    JHJTabBarCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor redColor];
    JHJTabBarModel *model = [[JHJTabBarModel alloc] init];
    model.image = [UIImage imageNamed:@"6.jpg"];
    cell.model = model;
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
